<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="layout">
<head>
    <title>118，我给母校发红包</title>

</head>
<body>
<section layout:fragment="content">
    <div class="main">
        <div class="logo">
            <img src="" th:src="@{/static/img/logo1.png}"/>
        </div>
        <ul class="ui-row op">
            <li class="ui-col ui-col-50 ">
                <label><input type="radio"  name="userType" checked="checked" value="1" class="userType" />校友</label>
            </li>
            <li class="ui-col ui-col-50">
                <label><input type="radio"  name="userType" value="2" class="userType" />北大之友</label>
            </li>
        </ul>
    </div>

    <img id="qrcodepay" style="vertical-align: middle;display: block;margin: 60px auto 20px;width:286px; height:286px" src="/peking/prepay/qrcode/pay?tid=${tid}"/>

    <script src="/static/js/json2.js" th:src="@{/static/js/json2.json}"/>
    <script>
        $(function(){
            var $fqzjl = $("#fqzjl"),  //发起按钮
                    $definedNum = $(".definedNum"), //自定义个数
                    $uNum = $(".uNum"), //所选择的几个红包
                    $zjlName = $(".zjlName"), //召集令名称
                    uMoney = 1.18;
            $uNum.on("click",function(){
                $uNum.removeClass("active");
                $(this).addClass("active");
                var _v = parseInt($(this).text()).toFixed(0);
                $definedNum.val("")
            });
            $definedNum.on("keyup",function(){
                var _v = parseInt($(this).val());
                if(_v>0){
                    $uNum.removeClass("active");
                    $(this).val(_v);
                }
            }).on("blur",function(){
                if( 0 >= $(this).val() ){
                    $(this).val(1);
                }
            });
            $fqzjl.on("click",function(){
                var _uType = $(".userType:checked").val();
                var $active = $(".uNum.active");
                var _uNum=0;
                if($definedNum.val()){
                    _uNum = $definedNum.val();
                }else if(!$active.hasClass("noLimite")){
                    _uNum = parseInt($active.text())
                }else if($active.hasClass("noLimite")){
                    _uNum = -1;
                }
                var _zjlName = $zjlName.val();
                var data = {'uType':_uType,'name' :_zjlName,'totalShare':_uNum};
                if(_zjlName != ""){
                    $.ajax({
                        type:"POST",
                        contentType: 'application/json',
                        url: "/peking/gift-call/save",
                        data:JSON.stringify(data),
                        success:function(res){
                            alert(res);
                            if(res == "GC_SAVE_ERROR"){
                                alert("保存失败!");
                            }else{
                                window.location.href = "/peking/gift-call/"+res.result.id+"/success";
                            }
                        },
                        error:function(){

                        }
                    })
                }else{
                    alert("请输入姓名");
                    return false;
                }


            })
        })
    </script>

</section>

</body>
</html>